<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title><%= __('titLe') %></title>
    <link href="image/favicon.ico" rel="shortcut icon">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_607959_8t0w2txptnj.css">
    <link rel="stylesheet" href="css/base.css">
    <link rel="stylesheet" href="css/header.css">
    <link rel="stylesheet" href="css/registered.css">
    <link rel="stylesheet" href="/css/userInfo.css">
    <link rel="stylesheet" href="/css/loading.css">
</head>

<body>
    <%- include('base/particles'); %>
        <div class="app">
            <div class="register" @keydown="quickLogin">
                <%- include('base/header'); %>
                    <div class="login">
                            <div class="loading" v-show="!loading">
                                <div class="preloader_4">
                                    <span></span>
                                    <span></span>
                                    <span></span>
                                    <span></span>
                                    <span></span>
                                </div>
                        </div>
                            <form @submit.prevent="submit" class="clear">
                                <div class="welcomeregister">
                                    <%= __('resetpassword') %>
                                </div>
                                <div class="email">
                                    <%= __('resetEmail') %>
                                </div>
                                <input type="text" class="emailnumber input" v-model="inputtext.email">
                                <div class="emailVerification" v-if="true">
                                    <%= __('verificationCode') %>
                                </div>
                                <div class="emailsend" v-if="true">
                                    <input type="text" class="input sencode">
                                    <button type="button" class="emailsendNumber" @click="sendcode" :disabled="isfalse">
                                        <%= __('Sendverificationcode') %>
                                    </button>
                                </div>
                                <div class="password">
                                    <%= __('inputnewpassword') %>
                                </div>
                                <input type="password" class="emailnumber input" v-model="inputtext.password">
                                <div class="newpassword">
                                    <%= __('Confirmpassword') %>
                                </div>
                                <input type="password" class="emailnumber input" v-model="inputtext.rpassword">
                                <div class="agreementbox">
                                    <div class="protocol" v-show="showprotocol">
                                        <span>
                                            <%= __('HYPERPLAY') %>
                                        </span>
                                        <i class="arrow"></i>
                                    </div>
                                </div>
                                <div class="registered-one">
                                    <input type="submit" value="<%= __('ResetNow') %>" class="SignUpnow">
                                </div>
                            </form>

                    </div>
                    <%- include('base/footer'); %>
            </div>
        </div>
        <style>
            .register .login .clear .registered-one {
                height: 46px;
                float: right;
                padding-right: 0px;
                margin-top: 20px;
                position: relative;
                right: 50%;
                transform: translateX(50%);
            }
        </style>
        <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
        <script>
            var app = new Vue({
                el: '.login',
                data() {
                    return {
                        inputtext: {
                            email: '',//邮箱
                            password: '',//一次密码
                            rpassword: '',//二次密码
                        },
                        istrue: true,
                        ischeck: false,
                        maskfalse: false,
                        theuser: '',
                        information: '',
                        showprotocol: false,
                        refID: "",
                        isfalse: false,
                        loading:false
                    };
                },
                created() {
                    if (window.sessionStorage.getItem('refererId') && window.sessionStorage.getItem('refererId') != "") {
                        this.refID = window.sessionStorage.getItem('refererId')
                    }
                },
                mounted(){
                    this.loading=true
                },
                methods: {
                    submit() {
                        let lang = this.getCookie("lang");
                        if (this.inputtext.email==null || /^\s*$/.test(this.inputtext.email) ) {
                           var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                            document.querySelector('.login').insertAdjacentHTML('afterBegin',a)
                            var b='<div class="maskLayer"></div>'
                            document.querySelector('.login').insertAdjacentHTML('afterBegin',b)
                            document.getElementsByClassName("closeinfo")[0].onclick=function(){
                            var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                            var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                            document.querySelector('.login').removeChild(c)
                            document.querySelector('.login').removeChild(d)
                            }
                            if (lang == "en_US") {
                                document.getElementsByClassName('errorMessageTop')[0].innerHTML="Reset Failed"
                                document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Please enter the email"
                            } else if (lang == "zh_TW") {
                                document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失敗"
                                document.getElementsByClassName('errorMessageBottom')[0].innerHTML="請先輸入郵箱"
                            } else {
                                 document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失败"
                                 document.getElementsByClassName('errorMessageBottom')[0].innerHTML="请先输入邮箱"
                            }
                            return
                        }
                        if (this.inputtext.password.length < 6 || this.inputtext.rpassword.length < 6) {
                           var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                            document.querySelector('.login').insertAdjacentHTML('afterBegin',a)
                            var b='<div class="maskLayer"></div>'
                            document.querySelector('.login').insertAdjacentHTML('afterBegin',b)
                            document.getElementsByClassName("closeinfo")[0].onclick=function(){
                            var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                            var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                            document.querySelector('.login').removeChild(c)
                            document.querySelector('.login').removeChild(d)
                            }
                            if (lang == "en_US") {
                                document.getElementsByClassName('errorMessageTop')[0].innerHTML="Reset Failed"
                                document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Password length cannot be less than 6"
                            } else if (lang == "zh_TW") {
                                document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失敗"
                                document.getElementsByClassName('errorMessageBottom')[0].innerHTML="密碼長度不能小於6位"
                            } else {
                                 document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失败"
                                 document.getElementsByClassName('errorMessageBottom')[0].innerHTML="密码长度不能小于6位"
                            }
                            return
                        }
                        if (this.inputtext.password !=this.inputtext.rpassword ) {
                             var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                            document.querySelector('.login').insertAdjacentHTML('afterBegin',a)
                            var b='<div class="maskLayer"></div>'
                            document.querySelector('.login').insertAdjacentHTML('afterBegin',b)
                            document.getElementsByClassName("closeinfo")[0].onclick=function(){
                            var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                            var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                            document.querySelector('.login').removeChild(c)
                            document.querySelector('.login').removeChild(d)
                            }
                            if (lang == "en_US") {
                                 document.getElementsByClassName('errorMessageTop')[0].innerHTML="Reset Failed"
                                 document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Inconsistent password"
                            } else if (lang == "zh_TW") {
                                 document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失敗"
                                 document.getElementsByClassName('errorMessageBottom')[0].innerHTML="密碼不一致"
                            } else {
                                document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失败"
                                document.getElementsByClassName('errorMessageBottom')[0].innerHTML="密码不一致"
                            }
                            return
                        }
                        if(document.getElementsByClassName("sencode")[0].value==""){
                            var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                            document.querySelector('.login').insertAdjacentHTML('afterBegin',a)
                            var b='<div class="maskLayer"></div>'
                            document.querySelector('.login').insertAdjacentHTML('afterBegin',b)
                            document.getElementsByClassName("closeinfo")[0].onclick=function(){
                            var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                            var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                            document.querySelector('.login').removeChild(c)
                            document.querySelector('.login').removeChild(d)
                            }
                            if (lang == "en_US") {
                                 document.getElementsByClassName('errorMessageTop')[0].innerHTML="Reset Failed"
                                 document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Please enter verification code"
                            } else if (lang == "zh_TW") {
                                 document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失敗"
                                 document.getElementsByClassName('errorMessageBottom')[0].innerHTML="請輸入驗證碼"
                            } else {
                                document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失败"
                                document.getElementsByClassName('errorMessageBottom')[0].innerHTML="请输入验证码"
                            }
                            return
                        }
                        if(document.getElementsByClassName("sencode")[0].value.length!=6){
                            var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                            document.querySelector('.login').insertAdjacentHTML('afterBegin',a)
                            var b='<div class="maskLayer"></div>'
                            document.querySelector('.login').insertAdjacentHTML('afterBegin',b)
                            document.getElementsByClassName("closeinfo")[0].onclick=function(){
                            var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                            var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                            document.querySelector('.login').removeChild(c)
                            document.querySelector('.login').removeChild(d)
                            }
                            if (lang == "en_US") {
                                 document.getElementsByClassName('errorMessageTop')[0].innerHTML="Reset Failed"
                                 document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Invalid verification code format"
                            } else if (lang == "zh_TW") {
                                 document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失敗"
                                 document.getElementsByClassName('errorMessageBottom')[0].innerHTML="驗證碼格式有誤"
                            } else {
                                document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失败"
                                document.getElementsByClassName('errorMessageBottom')[0].innerHTML="验证码格式有误"
                            }
                            return
                        }
                        let parm = {
                            email: this.inputtext.email,
                            password: this.inputtext.password,
                            checkCode: parseFloat(document.getElementsByClassName("sencode")[0].value)
                        }
                        axios.post('/user/forgetPassword', parm).then(res => {
                            if (res.data.code == 200) {
                                var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                                document.querySelector('.login').insertAdjacentHTML('afterBegin',a)
                                var b='<div class="maskLayer"></div>'
                                document.querySelector('.login').insertAdjacentHTML('afterBegin',b)
                                document.getElementsByClassName("closeinfo")[0].onclick=function(){
                                    var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                                    var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                                    document.querySelector('.login').removeChild(c)
                                    document.querySelector('.login').removeChild(d)
                                }
                                if (lang == "en_US") {
                                     document.getElementsByClassName('errorMessageTop')[0].innerHTML="Reset Successfully"
                                     document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Reset successfully"
                                } else if (lang == "zh_TW") {
                                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置成功"
                                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="密碼重置成功"
                                } else {
                                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置成功"
                                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="密码重置成功"
                                }
                                this.old = "";
                                this.newp = "";
                                this.Confirmnew = "";
                                location.href = '/singin';
                                return;
                            } else if (res.data.code == -10003) {
                                var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                                document.querySelector('.login').insertAdjacentHTML('afterBegin',a)
                                var b='<div class="maskLayer"></div>'
                                document.querySelector('.login').insertAdjacentHTML('afterBegin',b)
                                document.getElementsByClassName("closeinfo")[0].onclick=function(){
                                    var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                                    var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                                    document.querySelector('.login').removeChild(c)
                                    document.querySelector('.login').removeChild(d)
                                }
                                if (lang == "en_US") {
                                     document.getElementsByClassName('errorMessageTop')[0].innerHTML="Reset Failed"
                                     document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Incorrect verification code"
                                } else if (lang == "zh_TW") {
                                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失敗"
                                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="驗證碼輸入錯誤"
                                } else {
                                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失败"
                                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="验证码输入错误"
                                }
                                this.old = "";
                                this.newp = "";
                                this.Confirmnew = "";
                                return;
                            } else if (res.data.code == -10007) {
                                var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                                document.querySelector('.login').insertAdjacentHTML('afterBegin',a)
                                var b='<div class="maskLayer"></div>'
                                document.querySelector('.login').insertAdjacentHTML('afterBegin',b)
                                document.getElementsByClassName("closeinfo")[0].onclick=function(){
                                    var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                                    var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                                    document.querySelector('.login').removeChild(c)
                                    document.querySelector('.login').removeChild(d)
                                }
                                if (lang == "en_US") {
                                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="Reset Failed"
                                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Verification code expired"
                                } else if (lang == "zh_TW") {
                                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失敗"
                                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="驗證碼過期"
                                } else {
                                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失败"
                                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="验证码过期"
                                }
                                this.old = "";
                                this.newp = "";
                                this.Confirmnew = "";
                                return;
                            } else if (res.data.code == -10009) {
                                var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                                document.querySelector('.login').insertAdjacentHTML('afterBegin',a)
                                var b='<div class="maskLayer"></div>'
                                document.querySelector('.login').insertAdjacentHTML('afterBegin',b)
                                document.getElementsByClassName("closeinfo")[0].onclick=function(){
                                    var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                                    var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                                    document.querySelector('.login').removeChild(c)
                                    document.querySelector('.login').removeChild(d)
                                }
                                if (lang == "en_US") {
                                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="Reset Failed"
                                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Incorrect verification code"
                                } else if (lang == "zh_TW") {
                                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失敗"
                                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="驗證碼輸入錯誤"
                                } else {
                                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失败"
                                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="验证码输入错误"
                                }
                                this.old = "";
                                this.newp = "";
                                this.Confirmnew = "";
                                return;
                            }
                        })
                    },
                    sendcode() {
                        let lang = this.getCookie("lang");
                        let regValid = (/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)
                        if (this.inputtext.email == undefined || this.inputtext.email == "") {
                             var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                                document.querySelector('.login').insertAdjacentHTML('afterBegin',a)
                                var b='<div class="maskLayer"></div>'
                                document.querySelector('.login').insertAdjacentHTML('afterBegin',b)
                                document.getElementsByClassName("closeinfo")[0].onclick=function(){
                                    var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                                    var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                                    document.querySelector('.login').removeChild(c)
                                    document.querySelector('.login').removeChild(d)
                                }
                            if (lang == "en_US") {
                                document.getElementsByClassName('errorMessageTop')[0].innerHTML="Reset Failed"
                                document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Please fill in the complete information."
                            } else if (lang == "zh_TW") {
                                document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失敗"
                                document.getElementsByClassName('errorMessageBottom')[0].innerHTML="郵箱不能為空"
                            } else {
                                document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失败"
                                document.getElementsByClassName('errorMessageBottom')[0].innerHTML="邮箱不能为空"
                            }
                            return
                        }
                         if (!regValid.test(this.inputtext.email)) {
                                var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                                    document.querySelector('.login').insertAdjacentHTML('afterBegin',a)
                                    var b='<div class="maskLayer"></div>'
                                    document.querySelector('.login').insertAdjacentHTML('afterBegin',b)
                                    document.getElementsByClassName("closeinfo")[0].onclick=function(){
                                        var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                                        var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                                        document.querySelector('.login').removeChild(c)
                                        document.querySelector('.login').removeChild(d)
                                    }
                                if (lang == "en_US") {
                                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="Reset Failed"
                                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Please enter the correct email address."
                                } else if (lang == "zh_TW") {
                                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失敗"
                                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="請您輸入正確的郵箱地址"
                                } else {
                                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失败"
                                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="请您输入正确的邮箱地址"
                                }
                                return
                            }
                        let parm={
                            email:this.inputtext.email
                        }
                        axios.post('/user/eamilcheck',parm).then(res=>{
                            if(res.data.code==200){
                                var a=  '<div class="errorMessage"><div class="errorMessageTop" v-html="theuser"></div> <div class="errorMessageBottom" v-html="information"></div><img src="/image/close.png" alt="" class="closeinfo"></div>' 
                                document.querySelector('.login').insertAdjacentHTML('afterBegin',a)
                                var b='<div class="maskLayer"></div>'
                                document.querySelector('.login').insertAdjacentHTML('afterBegin',b)
                                document.getElementsByClassName("closeinfo")[0].onclick=function(){
                                    var c= document.getElementsByClassName('maskLayer')[0]  //移除元素
                                    var d=document.getElementsByClassName('errorMessage')[0] //移除元素
                                    document.querySelector('.login').removeChild(c)
                                    document.querySelector('.login').removeChild(d)
                                }
                                if (lang == "en_US") {
                                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="Reset Failed"
                                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="Email does not exist."
                                } else if (lang == "zh_TW") {
                                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失敗"
                                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="郵箱不存在"
                                } else {
                                    document.getElementsByClassName('errorMessageTop')[0].innerHTML="重置失败"
                                    document.getElementsByClassName('errorMessageBottom')[0].innerHTML="邮箱不存在"
                                }
                                return
                            }
                            if(res.data.code==-10002){
                                 let params = {
                                    type: 7,
                                    sendTo: this.inputtext.email
                                }
                                axios.post('/comm/mail/send', params).then(res => {
                                })
                                this.isfalse = true
                                let time = 60
                                let that =this
                                document.getElementsByClassName('emailsendNumber')[0].style.background = "#e9e9e9"
                                let sendtime = setInterval(function () {
                                    time -= 1
                                    document.getElementsByClassName('emailsendNumber')[0].innerHTML = time + "s"
                                    if (time == 0) {
                                        if (lang == "en_US") {
                                            document.getElementsByClassName('emailsendNumber')[0].innerHTML = "send code"
                                        } else if (lang == "zh_TW") {
                                            document.getElementsByClassName('emailsendNumber')[0].innerHTML = "發送驗證碼"
                                        } else {
                                            document.getElementsByClassName('emailsendNumber')[0].innerHTML = "发送验证码"
                                        }
                                        document.getElementsByClassName('emailsendNumber')[0].style.background = "white"
                                        that.isfalse=false
                                        clearInterval(sendtime)
                                    }
                                }, 1000)
                                }
                            })
                    },
                    quickLogin: function (e) {//回车及Enter登录
                        if (e.keyCode == 13 || e.keyCode == 108) {
                            this.login();
                        }
                    },
                    getCookie(cookiename) {
                        //获取cookie
                        var arr,
                            reg = new RegExp("(^| )" + cookiename + "=([^;]*)(;|$)");
                        if ((arr = document.cookie.match(reg))) {
                            return unescape(arr[2]);
                        } else {
                            return null;
                        }
                    },
                    CheckAgreement() {
                        this.ischeck = !this.ischeck
                    },
                }
            })
        </script>
</body>

</html>